/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.delivery.dto;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.validation.constraints.NotNull;

/**
 *
 * @author Jana Nemcova
 */
public class UserDTO implements Serializable,Cloneable{
   private Long id;
 
    @NotNull
    private String login;
    
    @NotNull
    private ContactDTO contact;

    private Set<DeliveryDTO> deliveries = new HashSet<DeliveryDTO>();
      
    
    public UserDTO() {
        
    }
    

     public Set<DeliveryDTO> getDeliveries() {
        return deliveries;
    }

    public void setDeliveries(Set<DeliveryDTO> createdDelivery) {
        this.deliveries = createdDelivery;
    }

     public void addDelivery(DeliveryDTO delivery) {
        deliveries.add(delivery);
    }
     
     public boolean removeDelivery(DeliveryDTO delivery) {
      return  deliveries.remove(delivery);
     }
    
   
    
    public Long getId() {
        return id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public ContactDTO getContact() {
        return contact;
    }

    public void setContact(ContactDTO sender) {
        this.contact = sender;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 53 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final UserDTO other = (UserDTO) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        if ((this.login == null) ? (other.login != null) : !this.login.equals(other.login)) {
            return false;
        }
        return true;
    }

   
 @Override
    public String toString() {
        return "User{" + "id=" + getId() + ", login=" + getLogin() + ", contact=" + getContact() + ", deliveries=" + deliveries + '}';
    }
    
   
    
    
    
      
}
